package com.example.hibernate.program;

import java.util.Collection;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

public class Driver {

	public static void main(String[] args) {
		SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
		Session session = sessionFactory.openSession();
		Transaction transaction = session.beginTransaction();
		try {
			Employee employee = (Employee) session.get(Employee.class, 1L);
			Collection<Address> addresses = employee.getAddresses();
//			int size = addresses.size();
			transaction.commit();
		} catch (Exception e) {
			transaction.rollback();
		}		
		session.close();
		sessionFactory.close();
	}
}
